package cn.com.bluemoon.daps.standard.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import cn.com.bluemoon.daps.common.enums.ReferRulesType;
import cn.com.bluemoon.daps.common.enums.StandardDataType;
import cn.com.bluemoon.daps.standard.dto.AddCheck;
import cn.com.bluemoon.daps.standard.dto.ExcelImportGroup;
import cn.com.bluemoon.daps.standard.dto.IExcelSourceModel;
import cn.com.bluemoon.daps.standard.dto.UpdateCheck;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * <p>
 * 指标标准表
 * </p>
 *
 * @author admin
 * @since 2020-08-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors
@ApiModel(value = "DapStandardIndex", description = "指标标准表")
public class DapStandardIndex extends BasePublishInfoOfStandard<DapStandardIndex>
        implements IExcelModel, IExcelDataModel, IExcelSourceModel, Serializable {

    private static final long serialVersionUID = 1L;

    public enum StdIndexType {
        /**
         * 指标
         */
        INDEX_1(1, "原子指标"),
        INDEX_2(2, "派生指标"),
        INDEX_3(3, "计算指标");
        @Getter
        private Integer type;
        @Getter
        private String name;

        StdIndexType(Integer type, String name) {
            this.name = name;
            this.type = type;
        }
    }

    @ApiModelProperty(value = "数据源系统")
    private String dataSourceSystem;

    @Size(max = 500, message = "取数逻辑不可大于{max}")
    @ApiModelProperty(value = "取数逻辑")
    private String accessLogic;

    @Size(max = 200, message = "数仓加工逻辑不可大于{max}")
    @ApiModelProperty(value = "数仓加工逻辑")
    private String dataWarehouseMakeLogic;

    @Size(max = 200, message = "数仓模型表不可大于{max}")
    @ApiModelProperty(value = "数仓模型表")
    private String dataWarehouseModel;

    @TableField(exist = false)
    @ApiModelProperty("数仓模型名")
    private String dataWarehouseModelName;

    @TableField(exist = false)
    @ApiModelProperty("数仓模型名表guid")
    private String dataWarehouseModelTableGuid;

    @TableField(exist = false)
    @ApiModelProperty("数仓模型名表guid")
    private String dataWarehouseModelTableMoiDataId;

    @TableField(exist = false)
    @ApiModelProperty("数仓模型名字段guid")
    private String dataWarehouseModelColumnGuid;

    @ApiModelProperty(value = "指标格式， 数值、金额")
    @EnumValue
    private StandardDataType indexFormat;

    @ApiModelProperty(value = "度量单位")
    @Size(max = 20, message = "度量单位不可大于{max}")
    private String commonUnits;

    @ApiModelProperty(value = "数据精度")
    @Size(max = 100, message = "数据精度不可大于{max}")
    private String dataAccuracy;

    /**
     * 新需求：增加指标类型属性：原子指标、派生指标、计算指标；
     * 影响属性：关联指标，原子指标没有关联指标
     */
    @ApiModelProperty("指标类型, 1原子指标、2派生指标、3计算指标 4维度（属性）")
    private Integer indexType;

    /**
     * 关联非本指标的其他已发布的指标standard_unique_id {@link DapStandardIndex#getStandardUniqueId()}
     */
    @ApiModelProperty(value = "关联指标")
    @Size(max = 200, message = "关联指标不可大于{max}")
    private String relatedIndex;

    @ApiModelProperty(value = "关联维度（多个）用英文逗号隔开")
    private String associationDimension;

    @ApiModelProperty(value = "取值范围")
    private String valueRange;

    @ApiModelProperty(value = "业务人员")
    @Size(max = 50, message = "业务人员不可大于{max}")
    private String businessPersonnel;

    @ApiModelProperty(value = "数据分析师")
    @Size(max = 50, message = "数据分析师不可大于{max}")
    private String dataAnalyst;

    @ApiModelProperty(value = "数仓开发人员")
    @Size(max = 50, message = "数仓开发人员不可大于{max}")
    private String dataWarehouseDeveloper;

//    @ApiModelProperty(value = "表主键id")
//    @NotBlank(message = "更新中主键信息不可为空", groups = {UpdateCheck.class})
//    @GsonExclusionField
//    private String id;

    @NotNull(message = "业务定义不可为空")
    @Size(max = 1024, message = "业务定义不可大于{max}")
    @NotNull(message = "业务定义不可为空", groups = {ExcelImportGroup.class})
    @Size(max = 1024, message = "业务定义不可大于{max}", groups = {ExcelImportGroup.class})
    @ApiModelProperty(value = "业务定义")
    @Excel(name = "业务定义")
    private String businessDefinition;

    @Size(max = 500, message = "计算公式不可大于{max}")
    @ApiModelProperty(value = "计算公式")
    private String calculationFormula;

    @ApiModelProperty(value = "数据长度，填充内容大于1的整数")
    @Size(max = 20, min = 0, message = "数据长度不可大于{max}")
    @Deprecated
    private String dateLength;

    @ApiModelProperty(value = "制定依据,枚举类型:1:国家标准、2:行业标准、3:内部标准")
    @EnumValue
    @Deprecated
    private ReferRulesType formulationBasis;

    @ApiModelProperty(value = "指标中文名称")
    @NotNull(message = "标准中文名不可为空")
    @Size(max = 512, message = "标准中文名不可大于{max}")
    @NotNull(message = "标准中文名不可为空", groups = {ExcelImportGroup.class})
    @Size(max = 512, message = "标准中文名不可大于{max}", groups = {ExcelImportGroup.class})
    @Excel(name = "*指标名称")
    private String indexChinName;

    @ApiModelProperty(value = "指标标准编码")
//    @Excel(name = "指标编号")
    private String indexCode;

    @NotNull(message = "指标英文名称不可为空")
    @Size(max = 50, message = "指标英文名称不可大于{max}")
    @NotNull(message = "指标英文名称不可为空", groups = {ExcelImportGroup.class})
    @Size(max = 50, message = "指标英文名称不可大于{max}", groups = {ExcelImportGroup.class})
    @ApiModelProperty(value = "指标英文名称")
    @Excel(name = "*英文名称")
    private String indexEngName;

    @Size(max = 500, message = "指标标准用途不可大于{max}")
    @Size(max = 500, message = "指标标准用途不可大于{max}", groups = {ExcelImportGroup.class})
    @ApiModelProperty(value = "指标标准用途")
    @Excel(name = "指标用途")
    private String indexUsage;

    @ApiModelProperty(value = "归属管理部门id")
    @NotBlank(message = "部门信息不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String managementDepartmentId;

    @ApiModelProperty(value = "一级分类")
    @NotBlank(message = "一级分类不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String primarySort;

    @ApiModelProperty(value = "二级分类")
    private String secondarySort;

    @ApiModelProperty(value = "所属主题")
    @NotBlank(message = "所属主题不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String theme;

    @ApiModelProperty(value = "三级分类")
    private String thirdSort;

    @ApiModelProperty(value = "业务线")
    @NotNull(message = "业务线不可为空")
    private Integer bizLineId;

    @ApiModelProperty(value = "导入excel文件错误行号", hidden = true)
    @TableField(exist = false)
    private int rowNum;

    @ApiModelProperty(value = "导入excel文件错误内容", hidden = true)
    @TableField(exist = false)
    private String errorMsg;

    @ApiModelProperty(value = " 应用名称")
    @Excel(name = "应用名称")
    @Size(max = 50, message = "应用名称不可大于{max}", groups = {ExcelImportGroup.class})
    @Deprecated
    private String indexAppName;

    @ApiModelProperty(value = "业务描述")
    @Excel(name = "业务描述")
    @Size(max = 500, message = "业务描述不可大于{max}", groups = {ExcelImportGroup.class})
    @Deprecated
    private String indexBizDesc;

    @ApiModelProperty(value = "指标展示名称")
    @Excel(name = "指标展示名称")
    @Size(max = 50, message = "指标展示名称不可大于{max}")
    private String indexSimpleName;

    @ApiModelProperty(value = "数据粒度")
    @Excel(name = "*数据粒度")
    @Size(max = 512, message = "数据粒度不可大于{max}")
    private String dataParticleSize;

    @ApiModelProperty(value = "管理人员")
    @Excel(name = "*管理人员")
    @Size(max = 50, message = "管理人员不可大于{max}")
    private String managePerson;


    @ApiModelProperty(value = "需求部门")
    @Excel(name = "*需求部门")
    @Size(max = 36, message = "需求部门不可大于{max}")
    private String demandDept;


    @ApiModelProperty(value = "变更原因")
    @Excel(name = "变更原因")
    @Size(max = 512, message = "变更原因不可大于{max}")
    private String modifyReason;

    @ApiModelProperty(value = "指标提出时间")
    @Excel(name = "指标提出时间")
    @Size(max = 50, message = "指标提出时间不可大于{max}")
    private String proposeTime;

}
